export const preview = {
  data() {
    // var checkPrice = (rule, value,callback) => {
    //   if((this.form.price<50&&this.form.price != 0)||this.form.price>1000000000||this.form.price<0||(this.form.price==''&&typeof(this.form.price)=='string')){
    //     console.log(111111111)
    //     return callback(new Error(this.$t('formRule.prace_rule')));
    //   } else {
    //     callback()
    //   }
    // };
    var checkCreator = (rule, value, callback) => {
      if (!this.form.creatorId) {
        return callback(new Error(this.$t('formRule.creator_rule')));
      } else {
        callback()
      }
    };
    var checkStartDate = (rule, value, callback) => {
      if (!this.form.previewStartTime) {
        return callback(new Error(this.$t('formRule.time_rule')));
      } else {
        callback()
      }
    };
    var checkEndDate = (rule, value, callback) => {
      if (!this.form.previewEndTime) {
        return callback(new Error(this.$t('formRule.time_rule')));
      } else {
        callback()
      }
    };
    // var checkImg = (rule, value, callback) => {
    //   if (!this.form.thumbnailId) {
    //     return callback(new Error(this.$t('formRule.poster_rule')));
    //   } else {
    //     callback()
    //   }
    // };
    var checkFile = (rule, value, callback) => {	
      if (!this.form.previewId) {
        return callback(new Error(this.$t('formRule.file_rule')));
      } else {
        callback()
      }
    };
    // var zh_TW = (rule,value,callback) => {
    //   if (!this.form.previewVideoName.zh_TW) {
    //     return callback(new Error(this.$t('formRule.arttnMovieName')));
    //   } else {
    //     callback()
    //   }
    // };
    var en_US = (rule,value,callback) => {
      if (!this.form.previewVideoName.en_US) {
        return callback(new Error(this.$t('formRule.artusMovieName')));
      } else {
        callback()
      }
    };
    // var ja_JP = (rule,value,callback) => {
    //   if (!this.form.previewVideoName.ja_JP) {
    //     return callback(new Error(this.$t('formRule.artjaMovieName')));
    //   } else {
    //     callback()
    //   }
    // };
    // var zh_CN = (rule,value,callback) => {
    //   if (!this.form.previewVideoName.zh_CN) {
    //     return callback(new Error(this.$t('formRule.artcnMovieName')));
    //   } else {
    //     callback()
    //   }
    // };
    // var d_zh_TW = (rule,value,callback) => {
    //   if (!this.form.description.zh_TW) {
    //     return callback(new Error(this.$t('formRule.inputPlaceholder')));
    //   } else {
    //     callback()
    //   }
    // };
    var d_en_US = (rule,value,callback) => {
      if (!this.form.introduction.en_US) {
        return callback(new Error(this.$t('formRule.inputPlaceholder')));
      } else {
        callback()
      }
    };
    // var d_ja_JP = (rule,value,callback) => {
    //   if (!this.form.description.ja_JP) {
    //     return callback(new Error(this.$t('formRule.inputPlaceholder')));
    //   } else {
    //     callback()
    //   }
    // };
    // var d_zh_CN = (rule,value,callback) => {
    //   if (!this.form.description.zh_CN) {
    //     return callback(new Error(this.$t('formRule.inputPlaceholder')));
    //   } else {
    //     callback()
    //   }
    // };
    return {
      mode: "add",
      defaultTime: [new Date(2000,1,1,23,59,59)],
      previewAction: '#',
      disabled: false,
      visible: false,
      isSaveing: false,
      vhTypeList: [
        {
          name: this.$t('short_data.video.typeHscreen'),
          value: 1
        },
        {
          name: this.$t('short_data.video.typeVscreen'),
          value: 2
        }
      ],
      shortDramaList: [],
      shortList: [],
      creatorIdList: [],
      form: {
        id: null,
        dramaKey: null,
        shortId: null,
        available: false,
        previewId: '',
        previewVhType: 2,
        previewStartTime: '',
        previewEndTime: '',
        previewVideoName: {
          en_US: '',
          ja_JP: '',
          zh_CN: '',
          zh_TW: '',
        },
        sort: 1,
        creatorId: '',
        introduction: {
          en_US: '',
          ja_JP: '',
          zh_CN: '',
          zh_TW: '',
        }
      },
      rules: {
        "previewVideoName.en_US": [
          {required: true, validator: en_US, trigger:'blur'}
        ],
        // "previewVideoName.ja_JP": [
        //   {required: true, validator: ja_JP, trigger:'blur'}
        // ],
        // "previewVideoName.zh_CN": [
        //   {required: true, validator: zh_CN, trigger:'blur'}
        // ],
        // "previewVideoName.zh_TW": [
        //   {required: true, validator: zh_TW, trigger:'blur'}
        // ],
        "previewStartTime": [
          {required: true, validator: checkStartDate, trigger:'change'}
        ],
        "previewEndTime": [
          {required: true, validator: checkEndDate, trigger:'change'}
        ],
        "creatorId": [
          {required: true, validator: checkCreator, trigger:'change'}
        ],
        "shortId": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],
        "previewId": [
          {required: true, validator: checkFile, trigger:'change'}
        ],
        "introduction.en_US": [
          {required: true, validator: d_en_US, trigger:'blur'}
        ],
        "dramaKey": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],
        // "description.ja_JP": [
        //   {required: true, validator: d_ja_JP, trigger:'blur'}
        // ],
        // "description.zh_CN": [
        //   {required: true, validator: d_zh_CN, trigger:'blur'}
        // ],
        // "description.zh_TW": [
        //   {required: true, validator: d_zh_TW, trigger:'blur'}
        // ],
      },
    }
  }
}